package com.wang.consumer.controller;

import com.wang.consumer.mapper.ConsumerMapper;
import com.wang.consumer.model.Consumer;
import com.wang.provider.api.client.ProviderClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: wangning
 * @date: 2023/12/25 13:48
 */
@RestController
public class ConsumerController {

    @Autowired
    private ProviderClient providerClient;

    @Autowired
    private ConsumerMapper consumerMapper;

    @GetMapping("/consumer/{id}")
    public Consumer consumer(@PathVariable("id") Integer id){
        Consumer consumer = consumerMapper.selectById(id);
        consumer.setProvider(providerClient.selectOne(id));
        return consumer;
    }

}
